package com.example.demo.controller;


import com.example.demo.entity.User;
import com.example.demo.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {


    @Autowired
    UserServiceImpl userServiceImpl;

    @RequestMapping("getUser")
    public User getUser(@RequestParam(value = "id") Long id) {
        return userServiceImpl.selectByPrimaryKey(1);
    }


    @RequestMapping("Register")
    public String Register(@RequestParam(value = "name") String name ,@RequestParam(value = "password") String password
            ,@RequestParam(value = "age") String age) {

        User user = new User();
        user.setName(name);
        user.setPassword(password);
        user.setAge(age);

        int i = userServiceImpl.insert(user);


        return i + "";
    }


}
